home *** CD-ROM | disk | FTP | other *** search
- Path: vixen.cso.uiuc.edu!usenet
- From: Dragos-Anton Manolescu <manolesc@uiuc.edu>
- Newsgroups: comp.lang.c++
- Subject: Q: throwing exceptions in constructors
- Date: 24 Mar 1996 19:51:11 -0600
- Organization: University of Illinois at Urbana-Champaign
- Message-ID: <opu3ze7xf4.fsf@sweetbay.will.uiuc.edu>
- Reply-To: Dragos Manolescu <manolesc@uiuc.edu>
- NNTP-Posting-Host: sweetbay.will.uiuc.edu
- X-Newsreader: Gnus v5.1
-
-
- Hi,
-
- I was wondering if it's possible to throw an exception from within a
- constructor (a word of caution: this is my first attempt to use
- exceptions :-) Suppose the constructor calls new and this fails. Then
- I would like to throw an exception to inform the calling program that
- an abnormal situation occured. Is this possible? I tried something
- like:
-
- ...
- MyClass myObject(1,2,3)
- ...
-
- inside a try statement but the compiler complained (I use g++ 2.7.2,
- BTW). Am I doing something wrong? What would be an elegant way to
- handle this?
-
- I would appreciate an e-mail reply, if possible. Thanx in advance for
- your time,
- --
- dam http://www.uiuc.edu/ph/www/manolesc
-